package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhPartner;
import com.laowang.project.system.service.MyCyhPartnerService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 合伙人Controller
 * 
 * @author laowang
 * @date 2024-01-08
 */
@Api(tags = "合伙人接口")
@RestController
@RequestMapping("/partner")
public class MyCyhPartnerController extends BaseController {
    @Autowired
    private MyCyhPartnerService myCyhPartnerService;


    @ApiOperation(value = "小程序端 合伙人列表",notes = "")
    @GetMapping("/web/list")
    public AjaxResult weblist() {

        List<MyCyhPartner> list = myCyhPartnerService.selectMyCyhPartnerList(null);
        return AjaxResult.success("操作成功",list);
    }


    /**
     * 查询合伙人列表
     */
    @ApiOperation(value = "查询合伙人列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:partner:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyCyhPartner myCyhPartner) {
        startPage();
        List<MyCyhPartner> list = myCyhPartnerService.selectMyCyhPartnerList(myCyhPartner);
        return getDataTable(list);
    }
    
    /**
     * 导出合伙人列表
     */
    @ApiOperation(value = "导出合伙人列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:partner:export')")
    @Log(title = "合伙人", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhPartner myCyhPartner) {
        List<MyCyhPartner> list = myCyhPartnerService.selectMyCyhPartnerList(myCyhPartner);
        ExcelUtil<MyCyhPartner> util = new ExcelUtil<MyCyhPartner>(MyCyhPartner.class);
        return util.exportExcel(list, "partner");
    }

    /**
     * 获取合伙人详细信息
     */
    @ApiOperation(value = "获取合伙人详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:partner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhPartnerService.selectMyCyhPartnerById(id));
    }

    /**
     * 新增合伙人
     */
    @ApiOperation(value = "新增合伙人",notes = "")
    @PreAuthorize("@ss.hasPermi('my:partner:add')")
    @Log(title = "合伙人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhPartner myCyhPartner) {
        return toAjax(myCyhPartnerService.insertMyCyhPartner(myCyhPartner));
    }

    /**
     * 修改合伙人
     */
    @ApiOperation(value = "修改合伙人",notes = "")
    @PreAuthorize("@ss.hasPermi('my:partner:edit')")
    @Log(title = "合伙人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhPartner myCyhPartner) {
        return toAjax(myCyhPartnerService.updateMyCyhPartner(myCyhPartner));
    }

    /**
     * 删除合伙人
     */
    @ApiOperation(value = "删除合伙人",notes = "")
    @PreAuthorize("@ss.hasPermi('my:partner:remove')")
    @Log(title = "合伙人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhPartnerService.deleteMyCyhPartnerByIds(ids));
    }
}
